/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javafeiq.ui;

import java.awt.BorderLayout;
import java.awt.HeadlessException;
import java.util.List;
import javafeiq.service.detect.ClientDetectUtil;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

/**
 *
 * @author bitray
 */
public class MainFrame extends JFrame {

    private final JScrollPane listpane = new JScrollPane();
    private JList userList = null;
    private final JPanel mainPanel = new JPanel();
    private final JPanel bottomPanel = new JPanel();
    private final JButton refreshButton = new JButton("刷新");
    private final JButton setButton = new JButton("设置");

    public MainFrame() throws HeadlessException {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setLayout(new BorderLayout());
        setSize(300, 600);
        init();
    }

    private void init() {
        ClientDetectUtil detectUtil = new ClientDetectUtil();
        List<String> list = detectUtil.getClientList();
        userList = new JList(list.toArray());
        listpane.getViewport().add(userList);
        this.add(listpane, BorderLayout.CENTER);

        bottomPanel.add(refreshButton);
        bottomPanel.add(setButton);
        this.add(bottomPanel, BorderLayout.SOUTH);
    }

}
